import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  HomeList({
    super.key,
  });

  final List notifyList = [
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(10),
      margin: const EdgeInsets.only(top: 10),
      child: Column(
        children: [
          Row(
            children: [
              Image.asset(
                'images/notice@2x.png',
                width: 25,
              ),
              const SizedBox(width: 8,),
              const Text(
                '社区',
                style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
              ),
              const Text('公告',
                  style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                      color: Colors.orange)),
            ],
          ),
          ListView(
            // 使用shrinkWrap参数来减小滚动视图的大小，使其仅包含其子元素
            shrinkWrap: true,
            // 禁止滚动操作，通过设置NeverScrollableScrollPhysics来锁定滚动视图，防止用户滚动
            physics: const NeverScrollableScrollPhysics(),
            children: notifyList.map((v) {
              return Container(
                margin: const EdgeInsets.only(top: 10),
                padding: EdgeInsets.all(20),
                decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(10)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(v['title']),
                    const SizedBox(
                      height: 5,
                    ),
                    Text(v['content']),
                    const SizedBox(
                      height: 5,
                    ),
                    Text(v['createdAt'])
                  ],
                ),
              );
            }).toList(),
          )
        ],
      ),
    );
  }
}
